package com.vnp.cooking.adapter;

import java.util.ArrayList;

import com.vnp.cooking.R;
import com.vnp.cooking.adapter.DetailDacDiemAdapter.ViewHolder;
import com.vnp.cooking.bean.ObjAttribute;
import com.vnp.cooking.utils.PreferenceHelper;
import com.vnp.cooking.utils.Utils;

import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;


public class DetailLoaiMonAdapter extends BaseAdapter{
	
	ArrayList<ObjAttribute> listDetails = new ArrayList<ObjAttribute>();
	Context context;
	PreferenceHelper preferenceHelper;
	Handler mHandler = new Handler();
	

	public DetailLoaiMonAdapter(Context context, ArrayList<ObjAttribute> listDetails) {
		super();
		this.context = context;
		this.listDetails = listDetails;
		preferenceHelper = new PreferenceHelper(context);
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		ViewHolder holder = null;
		if (v==null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			v = inflater.inflate(R.layout.list_item_detail_loaimon_ct, parent, false);
			holder = new ViewHolder();
			
			holder.txtDetails = (TextView) v.findViewById(R.id.txt_detail_dd);
			
			holder.txtDetails.setTypeface(Utils.getTypefaceRegular(context));
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		
		holder.txtDetails.setText(listDetails.get(position).getName());
		// Animation list
		final Animation animation = AnimationUtils.loadAnimation(context,R.anim.animation_list_text);
		v.startAnimation(animation);
		
		return v;
	}
	
	class ViewHolder {
		TextView txtDetails;
	}
	
	public void setDatachange(ArrayList<ObjAttribute> listDetails) {
		if (this.listDetails != null)
			this.listDetails = null;
		this.listDetails = listDetails;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return listDetails.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	
}
